<?php
$str = '<div class="row"><div class="col-sm-12 text-center"><nav><ul class="pagination">';

if ($this->curPage>1){
	$this->params[$this->varName] = $this->curPage-1;
	$str .= '<li><a href="' . U(YYK::$ctrlName, YYK::$methodName, $this->params) . '" aria-label="Previous"><span aria-hidden="true">«</span></a></li>';
}

if ($this->curPage>1){
	$this->params[$this->varName] = 1;
	$str .= '<li><a href="' . U(YYK::$ctrlName, YYK::$methodName, $this->params) . '">1</a></li>';
}
else{
	$str .= '<li class="active"><a>1</a></li>';
}

if ($this->curPage>4) {
	$str .= '<li><a>...</a></li>';
}

$from = ($this->curPage-2)>1 ? $this->curPage-2 : 2;
$to = ($this->curPage+2)<$this->pageCount ? $this->curPage+2 : $this->pageCount-1;

for ($i=$from; $i <= $to; $i++) {
	if ($i==$this->curPage) {
		$str .= '<li class="active"><a>'. $i .'</a></li>';
	}
	else{
		$this->params[$this->varName] = $i;
		$str .= '<li><a href="' . U(YYK::$ctrlName, YYK::$methodName, $this->params) . '">'. $i .'</a></li>';
	}
}

if ($this->curPage<$this->pageCount-3) {
	$str .= '<li><a>...</a></li>';
}

if ($this->curPage < $this->pageCount) {
	$this->params[$this->varName] = $this->pageCount;
	$str .= '<li><a href="' . U(YYK::$ctrlName, YYK::$methodName, $this->params) . '">'. $this->pageCount .'</a></li>';
}
else{
	$str .= '<li class="active"><a>'. $this->pageCount .'</a><li>';
}
if ($this->curPage < $this->pageCount) {
	$this->params[$this->varName] = $this->curPage+1;
	$str .= '<li><a href="' . U(YYK::$ctrlName, YYK::$methodName, $this->params) . '" aria-label="Next"><span aria-hidden="true">»</span></a></li>';
}

$str .= "</ul></nav></div></div>";


return $str;